import {addBaseUrl} from "@/utils/project";

export {parseTime} from '@/utils/index'

//是否可用
export const isUseTag = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": 'success',
        "2": 'dagger'
    };
    return statusMap[status]
};
//是否可用
export const isUse = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '可用',
        "2": '不可用'
    };
    return statusMap[status]
};

//是否隐藏
export const isHidden = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '展示',
        "2": '隐藏'
    };
    return statusMap[status]
};

//菜单类型
export const menuType = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '目录',
        "2": '菜单',
        "3": '目录按钮',
        "4": '菜单按钮'
    };
    return statusMap[status]
};

//是否可关闭
export const isAlwaysShow = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '不可关闭',
        "2": '可以关闭'
    };
    return statusMap[status]
};


// 请求颜色
export const excuteTimeStyle = (str: any) => {
    let time = str * 1;

    if (time >= 1 && time < 2) {
        return {
            color: '#8da10c',
            fontSize: '15px'
        }
    }
    if (time >= 2 && time < 4) {
        return {
            color: '#a17509',
            fontSize: '19px'
        }
    }

    if (time >= 4 && time < 6) {
        return {
            color: '#a10e0d',
            fontSize: '23px'
        }
    }
    if (time >= 6) {
        return {
            color: '#8607a1',
            fontSize: '27px'
        }
    }
};

// 请求图标
export const excuteTimeIcon = (str: any) => {
    let time = str * 1;
    if (time >= 1 && time < 2) {
        return "request-houzi";
    }
    if (time >= 2 && time < 4) {
        return "request-niu";
    }
    if (time >= 4 && time < 6) {
        return "request-kaola";
    }
    if (time >= 6) {
        return "request-woniu";
    }
};

//年月日
export const yMd = (str: any = null) => {
    let dateTime = new Date();
    if (str) {
        dateTime = new Date(str);
    }
    const YY = dateTime.getFullYear();
    const MM =
        dateTime.getMonth() + 1 < 10
            ? '0' + (dateTime.getMonth() + 1)
            : dateTime.getMonth() + 1;
    const D =
        dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate();
    return `${YY}-${MM}-${D}`;

};
//时分秒
export const HMS = (str: any = null) => {
    let dateTime = new Date();
    if (str) {
        dateTime = new Date(str);
    }
    const hh =
        dateTime.getHours() < 10
            ? '0' + dateTime.getHours()
            : dateTime.getHours();
    const mm =
        dateTime.getMinutes() < 10
            ? '0' + dateTime.getMinutes()
            : dateTime.getMinutes();
    const ss =
        dateTime.getSeconds() < 10
            ? '0' + dateTime.getSeconds()
            : dateTime.getSeconds();
    return `${hh}:${mm}:${ss}`;
};


//获取数组中第一张图片
export const getHead = (str: any) => {
    if (str && addBaseUrl(str).length > 0) {
        return addBaseUrl(str)[0].url;
    }
    return "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png";
};

//匹配状态过滤器
export const matchStatesFilter = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '匹配中',
        "2": '匹配完成',
        "3": '匹配失败',
        "4": '待匹配',
    };
    return statusMap[status]

};

// 审批状态筛选
export const approvalStatesFilter = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '待审批',
        "2": '已通过',
        "3": '已驳回',
    };
    return statusMap[status]

};

export const indexShowTopFilter = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '已置顶',
        "2": '未置顶',
    };
    return statusMap[status]

};

export const payTypeFilter = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '付费',
        "2": '免费',
        "3": '疫情期间免费',
        "4": '其他',
    };
    return statusMap[status]

};

export const upStatesFilter = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '已上架',
        "2": '已下架',
    };
    return statusMap[status];
};

export const imageTypeFilter = (status: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '上方',
        "2": '中间',
    };
    return statusMap[status];
};


// 审批状态筛选
export const subString = (str: any, length: any) => {
    if (!str) return str;
    if (str.length <= (length * 1)) {
        return str
    } else {
        return str.substring(0, length);
    }
};

//角色ID过滤器
export const roleIdFilter = (str: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '系统管理员',
        "2": '平台管理员',
        "11": '政府部门',
        "12": '企事业单位',
        "13": '个人用户',
        "14": '应用供应商',
    };
    return statusMap[str];
};


//证件类型
export const certificateTypeFilter = (str: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '身份证',
        "2": '组织机构代码证',
        "3": '营业执照',
    };
    return statusMap[str];
};


//用户审批状态
export const approvalStateFilter = (str: any) => {
    const statusMap: { [key: string]: string } = {
        "1": '待审批',
        "2": '已通过',
        "3": '已驳回',
    };
    return statusMap[str];
};

